let observerComponment = require('../../common/lib/observer').observerComponment;
let ble = require("../../util/ble")
let app = getApp()

Component(observerComponment({
	data: {
	
	},
	props: {
		store: require("./ble_con_store").ble_con_store
	},
	methods: {
		// 连接蓝牙设备
		ble_connect_dev(e) {
			let item_index = e.currentTarget.dataset.index
			let dev = this.props.store.dev_info[item_index]
			ble.connect_dev(dev).then(() => {
				// 连接成功
				this.props.store.hide_box()
			}, (res) => {
				this.props.store.hide_box()
				app.show_notice("连接失败了，并且不知道为啥失败的。")
			})
		},
		hide_dev_box() {
			this.props.store.hide_box()
			
		},
		// 滑动开始
		line_move_start(e) {
			this.props.store.move_start = e.changedTouches[0].pageY
		},
		// 滑动结束
		line_move_end(e)  {
			this.props.store.move_end = e.changedTouches[0].pageY
			
			if(this.props.store.move_end > this.props.store.move_start + 30 ) {
				this.props.store.hide_box()
			}
		},
		// 滑动滑动进行
		// 以后再写吧。就先这样用着。
		line_move(e) {
			
		}
	},
	
}))
